<template>
	<view class="resume-container">
		<view class="resume-head" :style="{ paddingTop: barHeight + 20 + 'rpx' }">
			<image src="@/static/img/arr.png" mode="" @click="goto"></image>
			<text class="title">简历详情</text>
		</view>
		<view class="resume-main">
			<view class="main-info">
				<view class="info-top">
					<view class="top-left">
						<view class="name">
							<view class="name-user">	{{ data.userInfo.appUserResume?.nickname }}</view>
					     <!-- <image src="/static/img/common/edi.png" mode="" @click="jump(1)"></image> -->
						</view>
						<view class="user">{{ data.userInfo.appUserResume?.sex === 'MALE' ? '男' : '女' }} | {{ data.userInfo.age }} | {{ setXl(data.userInfo.appUserResume?.education) }}</view>
					</view>
					<u-avatar size="42" v-if="data.userInfo.appUserResume?.avatarFileId" :src="httpUrl+'/app/file/viewFile?fileId='+ data.userInfo.appUserResume?.avatarFileId"></u-avatar>
					<u-avatar size="42" v-else :src="httpUrl+'/app/file/viewFile?fileId='+ uid"></u-avatar>
					
		<!-- 			<image style="height: 42rpx !important;" class="name-img" v-if="data.userInfo.appUserResume.avatarFileId" :src="httpUrl+'/app/file/viewFile?fileId='+ data.userInfo.appUserResume.avatarFileId" mode="widthFix" ></image>
					<image style="height: 42rpx !important;" class="name-img" v-else src="@/static/img/common/user.jpg" mode="" ></image> -->
				</view>
				<view class="phones">
					<image src="@/static/img/common/phone.png" mode=""></image>
					<view class="num">{{ maskPhoneNumber(data.userInfo.appUserResume?.linkPhone)  }}</view>
				</view>
			</view>
			<view class="main-qw" v-if="data.userInfo.appUserDesire[0]?.positionName">
				<view class="qw-top">
					<view class="top-title">求职期望</view>
					<!-- <image src="/static/img/common/edi.png" mode="" @click="jump(2)"></image> -->
				</view>
				<view class="qw-middle">
					<view class="middle-left">
						<view class="left-title">
							<text class="name">{{ data.userInfo.appUserDesire[0]?.positionName }}</text>
							<!-- <text class="money">{{ convertToK(data.userInfo.appUserDesire[0]?.salaryMin) }} - {{ convertToK(data.userInfo.appUserDesire[0]?.salaryMax) }}</text> -->
						  <text class="money" v-if="data.userInfo?.appUserDesire[0].salaryMin !== null">{{ convertToK(data.userInfo.appUserDesire[0].salaryMin) }} - {{ convertToK(data.userInfo.appUserDesire[0].salaryMax) }}</text>
						  <text class="money" v-if="data.userInfo?.appUserDesire[0].salaryMin === null">面议</text>
						</view>
						<view class="left-boder">
							<!-- <view class="border-item">{{ setName(data.userInfo.appUserDesire[0].expectWorkType) }}</view> -->
							<view class="border-item">{{ setName1(data.userInfo.appUserDesire[0]?.positionType) }}</view>
						</view>
						<view class="desc-time">工作时间: {{ data.userInfo.appUserDesire[0]?.workTime }}</view>
					</view>
				</view>
				<view class="qw-bt">
					<view class="bt-zw">{{ setName(data.userInfo.appUserDesire[0]?.expectWorkType) }}</view>
					<view class="bt-dz">{{ data.userInfo.appUserDesire[0]?.workProvinceName }} {{data.userInfo.appUserDesire[0]?.workCityName}} {{ data.userInfo.appUserDesire[0]?.workDistrictName }}</view>
				</view>
			</view>
			<view class="main-qw" v-if="!data.userInfo.appUserDesire[0]?.positionName">
				<view class="qw-top">
					<view class="top-title">求职期望</view>
					<!-- <image src="/static/img/common/edi.png" mode="" @click="jump(2)"></image> -->
				</view>
				<view class="mg-tp10">暂无数据</view>
			</view>
			<!-- 工作经历 -->
			<view class="main-jl">
				<view class="jl-top">
					<view class="jl-title">工作经历</view>
				</view>
				<view class="jl-content" v-if="data.userInfo.appUserWorkExperience[0]?.companyName">
					<view class="content-item">
						<view class="item-top">
							<view class="top-name">{{ data.userInfo.appUserWorkExperience[0]?.companyName }}</view>
							<view class="top-time">{{ data.userInfo.appUserWorkExperience[0]?.inTimeStart }} - {{ data.userInfo.appUserWorkExperience[0]?.inTimeEnd }}</view>
						</view>
						<view class="item-desc">{{ data.userInfo.appUserWorkExperience[0]?.workDesc }}</view>
					</view>
				</view>
				<view class="mg-tp10" v-else>暂无数据</view>
			</view>
			<view class="main-tc" v-if="data.userInfo.appUserResume?.introduction">
				<view class="tc-top">
					<view class="top-title">技能/特长</view>
				</view>
				<view class="tc-desc">{{ data.userInfo.appUserResume?.introduction }}</view>
			</view>
			<view class="main-tc" v-if="!data.userInfo.appUserResume?.introduction">
				<view class="tc-top">
					<view class="top-title">技能/特长</view>
				</view>
				<view class="mg-tp10">暂无数据</view>
			</view>
	
		</view>
		<!-- <t-index-address @select="select"></t-index-address>  -->
	</view>
</template>

<script setup>
import { ref, reactive, onMounted } from "vue"
import { onLoad } from '@dcloudio/uni-app'
import commonNavBar from "@/components/commonNavBar.vue";
import scrollView from "@/components/scrollView.vue";
import { getStatusBarHeight } from '@/utils/common/common.js'
import api from '@/utils/api/recruit.js'
import { getUserImInfo } from '@/utils/api/userInfo.ts'
import { TUILogin } from '@tencentcloud/tui-core';
const barHeight = ref(null)		
import { convertToK } from '@/utils/common/common.js'
onLoad(res => {
	uId.value = res.id
	barHeight.value = getStatusBarHeight()
})
const uid = uni.getStorageSync('avatarId')
onMounted(_ => {
	getDetail()
})
const uId = ref(null)
const httpUrl = getApp().globalData.baseUrl
const data = reactive({
	userInfo: {}
})
const getDetail = async _ => {
	const res = await api.getviewResume({id: uId.value })
	data.userInfo = res.data
}
const  maskPhoneNumber = (phoneNumber) => {
  // 确保输入是一个有效的手机号
  if (!/^\d{11}$/.test(phoneNumber)) {
    console.log('请输入有效的手机号');
    return;
  }

  // 将手机号转成数组并替换中间的几位为 '*'
  const masked = phoneNumber.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
  
  return masked;
}
const setName = (positionName) => {
	// 根据 positionName 返回不同的文字
	switch (positionName) {
		case 'FULL_TIME':
			return '全职';
		case 'PART_TIME_JOB':
			return '兼职';
		default:
			return '未知';
	}
}
const setName1 = (positionName) => {
	// 根据 positionName 返回不同的文字
	switch (positionName) {
		case 'OFFLINE':
			return '线下';
		case 'ONLINE':
			return '线上';
		default:
			return '未知';
	}
}
const setXl = (positionName) => {
	console.log(positionName);
	// 根据 positionName 返回不同的文字
	switch (positionName) {
		case 'NONE':
			return '不限';
		case 'PRIMARY_SCHOOL':
			return '小学';
		case 'JUNIOR_HIGH_SCHOOL':
			return '初中';
		case 'HIGH_SCHOOL':
			return '高中/中专/技校';
		case 'JUNIOR_COLLEGE':
			return '大专';
		case 'UNDERGRADUATE':
			return '本科';
		case 'GRADUATE_STUDENT':
			return '研究生';
		case 'DOCTOR':
			return '博士';
		case 'PROFESSOR':
			return '教授/专家';
		default:
			return '未知';
	}
}
// 编辑操作
const jump = index => {
	if(index === 1) {
		uni.navigateTo({ url: '/pages/resume/personal' })
	} else if(index === 2){
		uni.navigateTo({ url: '/pages/resume/jobExpectation' })
	} else if(index === 3) {
		uni.navigateTo({ url: '/pages/resume/jobRequirement' })
	} else if(index === 4) {
		uni.navigateTo({ url: '/pages/resume/skillStrengths' })
	} else {
		uni.navigateTo({ url: '/pages/resume/workExperience' })
	}
}
// 返回
const goto = _ => uni.navigateBack()
</script>

<style lang="scss">
.resume-container{
	width: 100%;
	height: 100vh;
	background: #fff;
	.resume-head{
		width: 100%;
		display: flex;
		align-items: center;
		// justify-content: space-between;
		width: 750rpx;
		height: 98rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		padding-left:32rpx;
		padding-right: 32rpx;
		box-sizing: border-box;
		image{
			width: 36rpx;
			height: 36rpx;
		}
		.title{
			width: 100%;
			flex: 1;
			font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
			font-weight: normal;
			font-size: 32rpx;
			color: #333333;
			// line-height: 48rpx;
			// text-align: center;
			font-style: normal;
			text-transform: none;
			margin-left: 269rpx;

		}
	}
	.resume-main{
		padding: 24rpx 32rpx;
		box-sizing: border-box;
		.main-info{
			padding-bottom: 32rpx;
			box-sizing: border-box;
			width: 100%;
			border-radius: 0rpx 0rpx 0rpx 0rpx;
			border-bottom: 1rpx solid #F4F6FA;
			.info-top{
				display: flex;
				align-items: center;
				justify-content: space-between;
				.top-left{
					.name{
						display: flex;
						align-items: center;
						.name-user{
							font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
							font-weight: normal;
							font-size: 48rpx;
							color: #000000;
							line-height: 72rpx;
							text-align: left;
							font-style: normal;
							text-transform: none;

						}
						.name-img{
							width: 42rpx;
							height: 42rpx !important;
							margin-left: 12rpx;
						}
					}
					.user{
						font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
						font-weight: normal;
						font-size: 32rpx;
						color: #595959;
						line-height: 48rpx;
						text-align: center;
						font-style: normal;
						text-transform: none;
						margin-top: 16rpx;
					}
				}
				image{
					width: 128rpx;
					height: 128rpx;
					border-radius: 50%;
				}
			}
			.phones{
				display: flex;
				align-items: center;
				margin-top: 19rpx;
				font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
				font-weight: normal;
				font-size: 32rpx;
				color: #595959;
				line-height: 48rpx;
				text-align: center;
				font-style: normal;
				text-transform: none;
				
				image{
					width: 42rpx;
					height: 42rpx;
					margin-right: 12rpx;
				}
			}
		}
		.main-qw{
			padding: 32rpx 0;
			box-sizing: border-box;
			border-radius: 0rpx 0rpx 0rpx 0rpx;
			border-bottom: 1rpx solid #F4F6FA;
			.qw-top{
				display: flex;
				align-items: center;
				justify-content: space-between;
				.top-title{
					font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
					font-weight: bold;
					font-size: 36rpx;
					color: #000000;
					line-height: 54rpx;
					text-align: left;
					font-style: normal;
					text-transform: none;
				}
				image{
					width: 48rpx;
					height: 48rpx;
				}
			}
			.qw-middle{
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-top: 16rpx;
				.middle-left{
					width: 100%;
					.left-title{
						width: 100%;
						display: flex;
						align-items: center;
						justify-content: space-between;
						.name{
							font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
							font-weight: normal;
							font-size: 32rpx;
							color: #262626;
							line-height: 48rpx;
							text-align: left;
							font-style: normal;
							text-transform: none;
						}
						.money{
							font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
							font-weight: normal;
							font-size: 36rpx;
							color: #6B64D3;
							line-height: 54rpx;
							text-align: left;
							font-style: normal;
							text-transform: none;
						}
					}
					.desc-time{
						font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
						font-weight: normal;
						font-size: 32rpx;
						color: #595959;
						line-height: 48rpx;
						text-align: left;
						font-style: normal;
						text-transform: none;
						margin-top: 12rpx;
					}
					.left-boder{
						margin-top: 12rpx; 
						display: flex;
						align-items: center;
						.border-item{
							padding: 6rpx 12rpx;
							box-sizing: border-box;
							font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
							font-weight: normal;
							font-size: 24rpx;
							color: #8C8C8C;
							line-height: 36rpx;
							text-align: left;
							font-style: normal;
							text-transform: none;
							margin-right: 10rpx;
							background: #F4F6FA;
							border-radius: 8rpx 8rpx 8rpx 8rpx;
						}
					}
				}
				image{
					width: 48rpx;
					height: 48rpx;
				}
			}
			.qw-bt{
				margin-top: 12rpx;
				display: flex;
				align-items: center;
				.bt-zw{
					font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
					font-weight: normal;
					font-size: 32rpx;
					color: #595959;
					line-height: 48rpx;
					text-align: left;
					font-style: normal;
					text-transform: none;
				}
				.bt-dz{
					font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
					font-weight: normal;
					font-size: 32rpx;
					color: #595959;
					line-height: 48rpx;
					text-align: left;
					font-style: normal;
					text-transform: none;
					margin-left: 20rpx;
				}
			}
		}
		.main-yq{
			padding: 32rpx 0;
			box-sizing: border-box;
			border-bottom: 1rpx solid #F4F6FA;
			.yq-top{
				display: flex;
				align-items: center;
				justify-content: space-between;
				.top-title{
					font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
					font-weight: bold;
					font-size: 36rpx;
					color: #000000;
					line-height: 54rpx;
					text-align: left;
					font-style: normal;
					text-transform: none;
				}
				image{
					width: 48rpx;
					height: 48rpx;
				}
			}
			.yq-desc{
				margin-top: 16rpx;
				.desc-time{
					font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
					font-weight: normal;
					font-size: 32rpx;
					color: #595959;
					line-height: 48rpx;
					text-align: left;
					font-style: normal;
					text-transform: none;
				}
				.desc-qy{
					font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
					font-weight: normal;
					font-size: 32rpx;
					color: #595959;
					line-height: 48rpx;
					text-align: left;
					font-style: normal;
					text-transform: none;
				}
			}
		}
		.main-tc{
			padding: 32rpx 0;
			box-sizing: border-box;
			border-bottom: 1rpx solid #F4F6FA;
			.tc-top{
				display: flex;
				align-items: center;
				justify-content: space-between;
				.top-title{
					font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
					font-weight: bold;
					font-size: 36rpx;
					color: #000000;
					line-height: 54rpx;
					text-align: left;
					font-style: normal;
					text-transform: none;
				}
				image{
					width: 48rpx;
					height: 48rpx;
				}
			}
			.tc-desc{
				margin-top: 16rpx;
				font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
				font-weight: normal;
				font-size: 32rpx;
				color: #595959;
				line-height: 48rpx;
				text-align: left;
				font-style: normal;
				text-transform: none;

			}
		}
		.main-jl{
			padding: 32rpx 0;
			box-sizing: border-box;
			border-bottom: 1rpx solid #F4F6FA;
			.jl-top{
				display: flex;
				align-items: center;
				justify-content: space-between;
				.jl-title{
					font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
					font-weight: bold;
					font-size: 36rpx;
					color: #000000;
					line-height: 54rpx;
					text-align: left;
					font-style: normal;
					text-transform: none;
				}
				image{
					width: 48rpx;
					height: 48rpx;
				}
			}
			.jl-content{
				margin-top: 8rpx;
				.content-item{
					.item-top{
						display: flex;
						align-items: center;
						justify-content: space-between;
						.top-name{
							font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
							font-weight: normal;
							font-size: 28rpx;
							color: #8C8C8C;
							line-height: 42rpx;
							text-align: left;
							font-style: normal;
							text-transform: none;
						}
						.top-time{
							font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
							font-weight: normal;
							font-size: 28rpx;
							color: #8C8C8C;
							line-height: 42rpx;
							text-align: left;
							font-style: normal;
							text-transform: none;
						}
					}
					.item-desc{
						font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
						font-weight: normal;
						font-size: 32rpx;
						color: #595959;
						line-height: 48rpx;
						text-align: left;
						font-style: normal;
						text-transform: none;
						margin-top: 16rpx;
					}
				}
			}
		}
	}
}
</style>
